home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.11 Nov 91 / Icon List source / CListObj.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-05  |  2.6 KB  |  64 lines  |  [TEXT/KAHL]

  1. /*    ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  2.     Object List
  3.  
  4.     Defines an object that holds a list of other objects and uses the 
  5.     List Manager to display them.
  6.     
  7.         * List is one-dimensional
  8.         * Objects in list must decendants of ItemObj object
  9.         * ListObj is 1 base, ie first item is item 1
  10.     |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
  11.  
  12. #define        CLASS_OBJLIST
  13.  
  14. #ifndef         CLASS_CITEMOBJ
  15. #include    "CItemObj.h"
  16. #endif
  17.  
  18. #ifndef         CLASS_COBJECT
  19. #include    "CObject.h"
  20. #endif
  21.  
  22. #ifndef    NULL
  23. #define    NULL            0L
  24. #endif
  25.  
  26. #define MYPROCID        42
  27.  
  28. /* :::::::::: LDEF dispatch routine definition :::::::::: */
  29. pascal void ListFunction ( int lMessage, Boolean lSelect, Rect *lRect, Cell lCell,
  30.                                     int lDataOffSet, int lDataLen, ListHandle lHandle );
  31.  
  32. /* :::::::::: list object :::::::::: */
  33. struct CListObj:CObject {
  34.                         /*** fields */
  35.     ListHandle        theList;                                        /* ROM List Manager list */
  36.     Rect                viewRect;                                    /* location of the view in the window (incl scroll bar) */
  37.     Boolean            drawIt;                                        /* drawing on or not */
  38.     
  39.                         /*** methods */
  40.     void                IList ( Rect *viewR,                    /* view rectangle in theWin coords */
  41.                                 int cellHeight,                    /* height of a row in pixels */
  42.                                 Boolean hasScrollBar,            /* true if vertical scroll bar */
  43.                                 int selectMethod,                    /* List Manager selection flags (zero is best) */
  44.                                 WindowPtr theWin );            /* window this list displays in */
  45.     void                Dispose ( void );                            /* throw away everything (but not objects in list) */
  46.     
  47.     Boolean            MouseInList ( Point thePoint,        /* location of mouse click */
  48.                                         int modifiers );            /* modifier keys */
  49.     void                UpdateList (RgnHandle updateRgn );/* update list (pass visRgn handle) */
  50.     void                ActivateList ( Boolean activate );    /* activate event for list, true or false */
  51.     void                DrawingOn ( Boolean drawing );    /* turns drawing of new objects on and off */
  52.     void                Scroll ( int amount );                    /* scroll by amoumt (+ is up) */
  53.     
  54.     int                NumObjs ( void );                        /* return number of objects in list */
  55.     void                Add ( CItemObj *theObject );        /* add a new object to the list */
  56.     void                Remove ( CItemObj *theObject );    /* remove the object from the list */
  57.     void                ForEach ( VoidFunc doThis );        /* execute the function, passing each object in the list */
  58.     void                ForEachSelected ( VoidFunc doThis ); /* same as ForEach, but only selected */
  59.     void                SelectNone ( void );                        /* de-select all */
  60.     Boolean            AnySelected ( void );                    /* return true if any objects are selected */
  61.     CItemObj        *FirstThat ( BooleanFunc test );    /* return first object in list that satisfies test */
  62.     CItemObj        *GetIndObject ( int n );                /* return nth object, if it exists */
  63.     };
  64.